var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
		balance: '0.00'
  },

  onLoad: function (options) {

  },
	
  onReady: function () {

  },

  onShow: function () {
		this.getUserGiftBalance()
  },

  onHide: function () {

  },

  onUnload: function () {

  },
	
	// 获取用户礼品卡余额
	getUserGiftBalance() {
		util.request(api.GetUserGiftBalance).then(res => {
			if (res.errno == '0') {
			  this.setData({
			    balance: res.data || '0.00'
			  })
			}
			else {
			}
		})
	},
	// 跳转消费记录
	goHistory() {
		wx.navigateTo({
		  url: "/pages/ucenter/balanceHistory/balanceHistory"
		});
	},
	// 跳转添加礼品卡
	goBalanceAdd() {
		wx.navigateTo({
		  url: "/pages/ucenter/balanceAdd/balanceAdd"
		});
	}

})